{% extends "main.html" %}

{% block content %}
<div class="content-box">
  <div class="content-box-header">
    <h3>Expenses</h3>
    <ul class="content-box-tabs">
      <li><a href="#tab1" class="default-tab">List</a></li>
      {% if user.is_staff %}
        <li><a href="/despesas/novo">Add Expense</a></li>
      {% endif %}
    </ul>
    <div class="clear"></div>
</div>

<div class="content-box-content">
  <div class="tab-content default-tab" id="tab1">
      
      <table>
        <thead>
          <tr>
            <th>N.º of Receipt</th>
            <th>Expense</th>
            <th>Name of Supplier</th>
            <th>Value (€)</th>
            <th>Date</th>
            <th>Details</th>
            <th>See Receipt</th>
            <th></th>
          </tr>
        </thead>
	{% for despesa in object_list %}
	  
	<tr> 
	  <td>{{despesa.nrFactura}}</td>
	  <td>{{despesa.despesa}}</td>
	  <td>{{despesa.nomeFornecedor}}</td>
	  <td>{{despesa.custo}}</td>
	  <td>{{despesa.data}}</td>
      <td>{{despesa.obs}}</td>
      <td><a href="/download/{{despesa.recibo.id}}">{{despesa.recibo}}</a></td>
      
	    <td><a href="{% url editar_despesa object_id=despesa.pk %}">Edit</a> | <a href="{% url apagar_despesa object_id=despesa.pk %}">Delete</a></td>
        </tr> 
	{% endfor %}
      </table>
      <p></p>
      <div class="notification error png_bg">
        <div>Total of Expenses: {{valorTotalDespesas}} €</div>
      </div>
      <div class="notification information png_bg">
        <div>Total Number of Expenses: {{nrTotalDespesas}}</div>
      </div>
    </div>
  </div>
</div>
{% endblock %}
